home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
lcppb.zip
/
LCPPANS.ZIP
/
ENCRYPT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-08
|
921b
|
41 lines
// encrypt.cpp -- Demonstrate encryption with XOR
#include <iostream.h>
main()
{
char password[129];
char anyString[129];
int i, j, count;
cout << "Enter your password: ";
cin >> password;
cout << "Enter a string (no blanks): ";
cin >> anyString;
cout << "Before encryption: " << anyString;
for (i = 0, j = 0; anyString[i] != 0; i++, j++) {
if (password[j] == 0)
j = 0;
anyString[i] ^= password[j];
}
count = i - 1;
cout << "\nAfter encryption: " << anyString;
for (i = 0, j = 0; i <= count; i++, j++) {
if (password[j] == 0)
j = 0;
anyString[i] ^= password[j];
}
cout << "\nAfter reencryption: " << anyString;
}
// Copyright (c) 1990 by Tom Swan. All rights reserved
// Revision 1.00 Date: 10/24/1990 Time: 07:34 am
// Revision 1.01 Date: 07/08/1991 Time: 05:41 pm
// Converted for Borland C++ 2.0